package com.itheima.util;


import com.itheima.exception.BusinessException;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtil {

    public static Date getTimeForStr(String time)  {
        Date parse = null;
        try {
            DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
            parse = dateFormat.parse(time);
        } catch (ParseException e) {
            throw new BusinessException("时间转换异常");
        }
        return parse;
    }



    public static Date getTimeForStrd(String time)  {
        Date parse = null;
        try {
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            parse = dateFormat.parse(time);
        } catch (ParseException e) {
            throw new BusinessException("时间转换异常");
        }
        return parse;
    }

}
